package domain.user;

import java.util.List;

import Persistent.*;

public class User {
	
	protected XmlLoggedOnUser user;

	public User(String fName , String lName, String userName, String email , String password, String signature){
		ObjectFactory factory = new ObjectFactory();
		this.user = factory.createXmlLoggedOnUser();
		
		user.setFName(fName);
		user.setLName(lName);
		user.setUserName(userName);
		user.setPassword(password);
		user.setSignature(signature);
		user.setEMail(email);
	}
	
	public User(XmlLoggedOnUser user)
	{
		this.user = user;
	}
	
	//getters
	public XmlLoggedOnUser getUser() {
		return user;
	}

	public String getFirstName() {
		return this.user.getFName();
	}
	public String getLastName() {
		return this.user.getLName();
	}
	public String getPassword() {
		return this.user.getPassword();
	}
	public String getSigniture() {
		return this.user.getSignature();
	}
	public String getUserName() {
		return this.user.getUserName();
	}
	public String getEmail() {
		return this.user.getEMail();
	}
	public List<XmlPost> getPosts() {
		return this.user.getPosts();
	}
	
	//setters
	public void setUser(XmlLoggedOnUser user) {
		this.user = user;
	}
	
	public void setSigniture(String signature) {
		this.user.setSignature(signature);
	}
	public void setFirstName(String fName) {
		this.user.setFName(fName);
	}
	public void setLastName(String lName) {
		this.user.setLName(lName);
	}
	public void setPassword(String password) {
		this.user.setPassword(password);
	}
	public void setUserName(String userName) {
		this.user.setUserName(userName);
	}
	public void setEmail(String email) {
		this.user.setEMail(email);
	}

	
	/**Function which adds new post to this user
	 * 
	 * @param post
	 * @return true (as specified by Collection.add(E))
	 */
	public boolean addNewPost(XmlPost post) 
	{		
		return this.user.getPosts().add(post);
	}
	
	/**
	 * 
	 * @return xml instance
	 */
	public XmlLoggedOnUser getXmlInstance()
	{
		return this.user;
	}
	
		
}
